package com.pb.web.action;

import com.opensymphony.xwork2.ActionSupport;
import com.pb.entity.User;

/**
 * 动态结果的作用
 * @author Jovi
 * 2015年12月28日
 * UserAction.java
 */
public class UserAction extends ActionSupport {

	private static final long serialVersionUID = -1783819998312712862L;

	// 下一个跳转到的Action
	private String nextDispose;
	private User user;

	/**
	 * 获取 user
	 * 
	 * @return user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * 设置 user
	 * 
	 * @param user
	 *            user
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * 获取 nextDispose
	 * 
	 * @return nextDispose
	 */
	public String getNextDispose() {
		return nextDispose;
	}

	/**
	 * 设置 nextDispose
	 * 
	 * @param nextDispose
	 *            nextDispose
	 */
	public void setNextDispose(String nextDispose) {
		this.nextDispose = nextDispose;
	}

	/**
	 * 处理用户登录，如果用户是普通用户，UserAction会跳转到CommonAction
	 * 如果用户是管理员用户，UserAction会跳转到AdminAction
	 */
	public String login() {
		if (user.getUserName().equals("common")
				&& user.getPassWord().equals("common")) {
			nextDispose = "common";
			return SUCCESS;
		} else if (user.getUserName().equals("admin")
				&& user.getPassWord().equals("admin")) {
			nextDispose = "admin";
			return SUCCESS;
		} else {
			return INPUT;
		}
	}
}
